/**
 *
 */
package com.lmx.repoDomain.repository;

import io.katharsis.queryParams.QueryParams;
import io.katharsis.repository.annotations.JsonApiFindAll;
import io.katharsis.repository.annotations.JsonApiResourceRepository;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Component;

import com.lmx.common.util.CommonUtil;
import com.lmx.repoDomain.tmodel.SalaryReportItem;

/**
 * 薪资月统计JsonApi
 *
 * @author djs 2018年4月3日
 */
@JsonApiResourceRepository(SalaryReportItem.class)
@Component
public class SalaryReportItemRepository extends BaseRepository<SalaryReportItem> {
	@PostConstruct
	public void init() {
		dslJpaService.setEntityClass(SalaryReportItem.class);
	}

	@Override
	@JsonApiFindAll
	public Iterable<SalaryReportItem> findAll(final QueryParams requestParams) {
		Iterable<SalaryReportItem> salaryReportItems = super.findAll(requestParams);
		for (SalaryReportItem srt : salaryReportItems) {
			if (!CommonUtil.integerTimeInMonth(srt.getRegularDate())) {
				srt.setRegularDate(null);// 正式
			}
			if (!CommonUtil.integerTimeInMonth(srt.getLeaveDate())) {
				srt.setLeaveDate(null);// 离职
			}
			if (!CommonUtil.integerTimeInMonth(srt.getOnjobDate())) {
				srt.setOnjobDate(null);// 入职
			}
		}
		return salaryReportItems;

	}
}
